﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DaInterFace;

namespace DaInterFace.XMode
{
    public interface IXClass
    {
        void Code(String meth, XCodeResult xcr);
    }

    public interface IXMode
    {
        event MessageHandler MessageEvent;

        IDataBase Data { get; }

        ISerializer Serializer { get; }

        IConfig Config { get; }
        void Message(MessageType type, String note);
        void Message(MessageType type, String note, Double span);
    }

    //public delegate void MessageHandler(MessageType type, String note, Double span);

    public class XCodeResult
    {
        public EnumResult Result;
        public String Message;
        public String Content;
        public SerialType SerialType;
    }

    public enum EnumResult : int
    {
        Normal = 0,
        Error = 1,
        ReLoad = 2
    }

    public class ConfigStruct
    {
        public Boolean Right { get { return _right; } }

        private Boolean _right;

        public ConfigStruct(String config)
        {
            if (config == null || config.Length != 1)
            {
                _right = false;
            }
            else
            {
                switch (config[0])
                {
                    case 'J':
                        SerialType = DaInterFace.SerialType.Json;
                        break;
                    case 'X':
                        SerialType = DaInterFace.SerialType.Xml;
                        break;
                }
            }
            _right = true;
        }
        public SerialType SerialType;
    }
}
